from typing import List


class Solution:
    def singleNumber(self, nums: List[int]) -> int:
        def mNum(nums, m):
            cnt = [0 for _ in range(32)]
            for num in nums:
                for bit in range(32):
                    cnt[bit] += (num >> bit) & 1
            ans = 0
            for bit in range(32):
                if cnt[bit] % m != 0:
                    ans |= (1 << bit)
            return ans

        ans = mNum(nums, 3)
        if ans > (1 << 31):
            return ans - (1 << 32)
        return ans


if __name__ == '__main__':
    s = Solution()
    r = s.singleNumber([1])
    print(r)
